import Vue from 'vue';
import App from './App';
import router from '@/routes.js';
import axios from 'axios';
import ElementUI from 'element-ui';

import 'element-ui/lib/theme-default/index.css';
import '@/style/reset.css';
import '@/style/base.css';
import '@/style/elchange.css';

Vue.config.productionTip = false;

Vue.prototype.$http = axios;

// Vue.prototype.h = 'http://192.168.199.160:8080/xwt_sys';
// Vue.prototype.h = 'http://120.24.75.6:8081/xwt_sys';
// Vue.prototype.h = 'http://192.168.1.5:8081/xwt_sys';
Vue.prototype.h = 'http://192.168.1.3:8080/xwt_sys';

axios.interceptors.response.use(
    response => {

    	if (response.data == 'Token失效') {
            router.replace({
                    path: '/login',
             })
            localStorage.removeItem('TOKEN'); 
        }
        return response;
    },
    error => {
    	// console.log(response.data);
     //    if (error.response) {
     //        switch (error.response.status) {
     //            case 401:
     //                // 返回 401 清除token信息并跳转到登录页面
     //                store.commit(types.LOGOUT);
     //                router.replace({
     //                    path: 'login',
     //                    query: {redirect: router.currentRoute.fullPath}
     //                })
     //        }
     //    }
     //    return Promise.reject(error.response.data)   // 返回接口返回的错误信息
    }
);


Vue.use(ElementUI);

new Vue({
	el: '#app',
	router,
	template: '<App/>',
	components: {
		App
	}
})